{% load wagtailcore_tags common_structured %}

{% if items %}
    <script type="application/ld+json">
        {
            "@context": "https://schema.org",
            "@type": "BreadcrumbList",
            "itemListElement": [
                {% for item in items %}
                    {
                        "@type": "ListItem",
                        "position": {{ forloop.counter }},
                        "item": {
                            "@id": "{{ root_url }}{% pageurl item %}",
                            "name": "{{ item.title|jsonldvalue }}"
                        }
                    }{% if not forloop.last %},{% endif %}
                {% endfor %}
            ]
        }
    </script>
{% endif %}
